﻿using System;
using System.Collections;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using UnityEngine;
using Utility.Math;

namespace Utility.Json
{
	public class Rotation4Converter : JsonConverter<Rotation4>
	{
		public override Rotation4 ReadJson (JsonReader reader, Type objectType, Rotation4 existingValue, bool hasExistingValue, JsonSerializer serializer)
		{
			JToken token = JToken.Load (reader);
			int val = token.Value<int> ();
			return new Rotation4 ((Rotation4.Dir)val);
		}

		public override void WriteJson (JsonWriter writer, Rotation4 value, JsonSerializer serializer)
		{
			writer.WriteValue (value.DirIndex);
		}
	}
}